import TextV from "~/components/TextV.vue";
import { BaseDialog } from "~/utils/BaseDialog";

export const useBaseDialog = () => {
  // 获取当前的 Vue 实例
  const { vueApp } = useNuxtApp();

  class DialogDemo extends BaseDialog {
    render() {
      const text = ref(122);

      return defineComponent(() => {
        return () =>
          h(TextV, {
            text: text.value,
            onClickMe: () => {
              text.value++;

              this.broadcastReceivers.emit("wake_up", () => {
                console.log("广播一个事件出去");
              });
            },
          });
      });
    }

    setContext() {
      return vueApp;
    }
  }

  return { DialogDemo };
};
